package com.zc.study

import org.apache.flink.api.scala.ExecutionEnvironment
import org.apache.flink.api.scala._

import scala.util.Random

object DataSetDataTrans {

  val fileBasePath = "D:\\gitee\\imooc_study\\test-data\\flink\\"

  def main(args: Array[String]): Unit = {
    val env = ExecutionEnvironment.createLocalEnvironment()
    val dataSet = env.readTextFile(fileBasePath + "transfer01.txt")

//    val words = dataSet.flatMap {
//      _.split(" ")
//    }

//    val words = dataSet.map(x => {
//      x.split(" ")
//    })
//    val list = List(words)
//    for (elem <- list) {
//      println(elem)
//    }


    //    mapPartition

    //    val dataSet = env.fromCollection(1 to 10).setParallelism(4) // 设置4个分区
    //    dataSet.mapPartition(x => {
    //      val tag = Random.nextInt(10)
    //      for (item <- x){
    //        println(tag+":keyiba:"+item)
    //      }
    //      x
    //    }).collect()
    val value = dataSet.distinct()
    value.print()

  }
}
